<?php

class Admin_Form_Curso extends Zend_Form {

    public function init() {
        // Set the method for the display form to POST
        $this->setMethod('post');
        $this->setAction('/admin/curso/save');
        $this->setAttrib('class', 'form-horizontal mini-layout-body');
        $this->addElement('hidden', 'codigo_curso');
        $this->addElement('text', 'nombre', array(
            'label' => 'Nombre:',
            'required' => true,
            'filters' => array('StringTrim'),
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(2, 50))
            )
        ));
        $this->addElement('text', 'fecha_inicio', array(
            'label' => 'Fecha Inicio:',
            'required' => false,
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 255))
            )
        ));

        $this->addElement('text', 'fecha_fin', array(
            'label' => 'Fecha Fin:',
            'required' => false,
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 255))
            )
        ));

        $this->addElement('text', 'cantidad_horas', array(
            'label' => 'Cantidad horas:',
            'required' => true,
            'class' => 'input-block-level',
            'validators' => array(
                array('validator' => 'Digits', 'options' => array(4, 100))
            )
        ));
        $area_academica = new Application_Model_Mapper_AreaAcademica();
        $area_db = $area_academica->fetchAll();
        $area = new Zend_Form_Element_Select('codigo_area_academica');
        foreach ($area_db as $value) {
            $a = $value->toArray();
            $area->addMultiOption($a['codigo_area_academica'], $a['nombre']);
        }

        $area->setLabel(('Área académica'));


        $this->addElement($area);
        $this->addElement('submit', 'submit', array(
            'ignore' => true,
            'label' => 'Guardar',
            'class' => 'btn btn-large btn-primary'
        ));
        $this->addElement('button', 'cancel', array(
            'ignore' => true,
            'label' => 'Cancelar',
            'onclick' => 'back()',
            'class' => 'btn btn-large btn-primary'
        ));
    }

}

?>
